use polars::prelude::*;
use crate::statistics::{Records, Statistics};
use anyhow::{Context, Result};

impl Records {
    pub fn to_series(&self, name: &str) -> Series {
        Series::new(name.into(), &self.data)
    }
}

impl Statistics {
    pub fn to_dataframe(&self) -> Result<DataFrame> {
        let df = DataFrame::new(
        vec![self.size.to_series("size").into(),
        self.resident.to_series("resident").into(),
        self.shared.to_series("shared").into(),
        self.trs.to_series("trs").into(),
        self.lrs.to_series("lrs").into(),
        self.drs.to_series("drs").into(),
        self.dt.to_series("dt").into(),])
        .with_context(|| "Failed to create dataframe")?;
        Ok(df)
    }
}